package com.jackiepenghe.filetest

import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import com.sscl.baselibrary.activity.BaseSplashActivityWithPermissionCheck

@SuppressLint("CustomSplashScreen")
class SplashActivity : BaseSplashActivityWithPermissionCheck() {
    /**
     * 权限请求失败
     */
    override fun permissionRequestFailed() {
        finish()
    }

    /**
     * 有权限被永久拒绝
     * @param failedPermissions 被拒绝的权限
     * @return 是否跳转到系统权限设置界面
     */
    override fun permissionsAlwaysDenied(failedPermissions: Array<String>): Boolean {
        return true
    }

    /**
     * 权限被用户拒绝
     * @param failedPermissions 被拒绝的权限
     * @return 是否继续进行权限请求
     */
    override fun permissionsDenied(failedPermissions: Array<String>): Boolean {
        return true
    }

    /**
     * 需要请求的权限
     */
    override fun permissionsNeedRequest(): Array<String> {
        return arrayOf(
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE
        )
    }

    /**
     * 权限请求成功
     */
    override fun permissionsRequested() {
        MyApp.instance.initCrashAndLogCat()
        val intent = Intent(this@SplashActivity, MainActivity::class.java)
        startActivity(intent)
        finish()
    }
}